<template>
  <div class="page-search">
    <MieForm v-bind="pageSearchConfig" v-model="formData">
      <template #header>
        <h2>高级检索</h2>
      </template>
      <template #footer>
        <div>
          <el-button :icon="Refresh" @click="emitReset">重置</el-button>
          <el-button type="primary" :icon="Search" @click="emitSearch"
            >搜索</el-button
          >
        </div>
      </template>
    </MieForm>
  </div>
</template>

<script setup lang="ts">
import { ref } from "vue";
import MieForm from "@/base-ui/form";
import { Search, Refresh } from "@element-plus/icons-vue";

defineProps({
  pageSearchConfig: {
    type: Object,
    default: () => {},
  },
});

let formData = ref({});
// for (const item of props.pageSearchConfig.formItems) {
//   formData.value[item.fileId] = "";
// }//这里不设置的话将会自动根据填写的被填充

const emit = defineEmits(["reset", "search"]);

const emitReset = () => {
  formData.value = {};
  emit("reset");
};
const emitSearch = () => {
  emit("search", formData.value);
};
</script>

<style lang="less" scoped></style>
